package com.sanbi.shield.server.controller;

import com.sanbi.common.vo.ResponseVo;
import com.sanbi.shield.common.repsonse.CommonResponse;
import com.sanbi.shield.server.biz.service.UserInfoService;
import com.sanbi.shield.server.common.bean.request.UserLoginRequest;
import com.sanbi.shield.server.common.bean.vo.ResourceTreeNodeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户访问Controller
 *
 * @author XiaoQingqing
 * @since 2024/07/27
 */
@Validated
@RestController
@Api(value="用户访问Container", tags={"用户访问"})
@RequestMapping("access")
public class UserAccessController {
    /**
     * 用户信息Service
     */
    @Resource
    private UserInfoService userInfoService;

    @PostMapping("login")
    @ApiOperation(value = "登录")
    public ResponseVo<String> login(@RequestBody @Validated UserLoginRequest request) {
        return ResponseVo.ok(userInfoService.login(request));
    }

    @GetMapping("/mobile/perm/tree")
    @ApiOperation(value = "查询移动端权限树")
    public ResponseVo<List<ResourceTreeNodeVO>> queryPermTree() {
        return ResponseVo.ok(userInfoService.queryPermTree());
    }

}
